package controlLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class PersonTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class PersonTest
{
    /**
     * Default constructor for test class PersonTest
     */
    public PersonTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void createPersonTest()
    {
        controlLayer.PersonCtrl personCt1 = new controlLayer.PersonCtrl();
        assertEquals(true, personCt1.createPerson("TestName", "TestAddress", "9000", "TestCity", "12345678"));
        assertEquals(true, personCt1.createPerson("TestName2", "TestAddress2", "9001", "TestCity2", "2345678"));
        assertEquals(true, personCt1.createPerson("TestName", "TestAddress", "9000", "TestCity", "34567890"));
        assertEquals(false, personCt1.createPerson("TestName", "TestAddress", "9000", "TestCity", "12345678"));
        assertEquals(false, personCt1.createPerson("TestName3", "TestAddress3", "9002", "TestCity3", "12345678"));
        personCt1.deletePerson("12345678");
        personCt1.deletePerson("2345678");
        personCt1.deletePerson("34567890");
    
    }
    
    

    @Test
    public void deletePersonTest()
    {
        controlLayer.PersonCtrl personCt1 = new controlLayer.PersonCtrl();
        assertEquals(false, personCt1.deletePerson("12345678"));
        personCt1.createPerson("TestName", "TestAddress", "9000", "TestCity", "12345678");
        assertEquals(false, personCt1.deletePerson("TestName"));
        assertEquals(false, personCt1.deletePerson("TestAddress"));
        assertEquals(false, personCt1.deletePerson("9000"));
        assertEquals(false, personCt1.deletePerson("TestCity"));
        assertEquals(false, personCt1.deletePerson("1234567"));
        assertEquals(true, personCt1.deletePerson("12345678"));
    }

    @Test
    public void findPersonTest()
    {
        controlLayer.PersonCtrl personCt1 = new controlLayer.PersonCtrl();
        assertEquals(false, personCt1.findPerson("12345678"));
        assertEquals(false, personCt1.findPerson("testname"));
        assertEquals(false, personCt1.findPerson("TestName"));
        personCt1.createPerson("TestName", "TestAddress", "9000", "TestCity", "12345678");
        assertEquals(true, personCt1.findPerson("TestName"));
        assertEquals(true, personCt1.findPerson("testname"));
        assertEquals(true, personCt1.findPerson("12345678"));
        assertEquals(false, personCt1.findPerson("1234567"));
        personCt1.deletePerson("12345678");
    }

    @Test
    public void personUpdateTest()
    {
        controlLayer.PersonCtrl personCt1 = new controlLayer.PersonCtrl();
        assertEquals(false, personCt1.updatePersonNow("12345678", "TestName2", "TestAddress2", "9001", "TestCity2", "2345678"));
        personCt1.createPerson("TestName", "TestAddress", "9000", "TestCity", "12345678");
        assertEquals(false, personCt1.updatePersonNow("1234567", "TestName2", "TestAddress2", "9001", "TestCity2", "2345678"));
        assertEquals(true, personCt1.updatePersonNow("12345678", "TestName2", "TestAddress2", "9001", "TestCity2", "12345678"));
        assertEquals(true, personCt1.updatePersonNow("12345678", "TestName2", "TestAddress2", "9001", "TestCity2", "2345678"));
        assertEquals(false, personCt1.updatePersonNow("12345678", "TestName2", "TestAddress2", "9001", "TestCity2", "2345678"));
        personCt1.deletePerson("2345678");
    }
}




